#include <iostream>
#include <string>
using namespace std;

class FactoryTemplate 
{
private:
	string path;
protected:
	virtual ~FactoryTemplate() {}
	virtual void findFiles(string path)=0;
	void readFileStream() 
	{
		cout << "read stream for the files" << endl;
	}
	virtual void decodeXml()=0;
	void buildFactory() 
	{
		cout << "create all of the products and load into factory" << endl;
	}
public:
	void initFactory(string path) 
	{
		this->path = path;
		this->findFiles(path);
		this->readFileStream();
		this->decodeXml();
		this->buildFactory();
	}
	void reloadFactory() 
	{
		this->initFactory(this->path);
	}
};

class TagFactory: public FactoryTemplate 
{
protected:
	void findFiles(string path) 
	{
		cout << "find the tag xml files from the path" << endl;
	}
	void decodeXml() 
	{
		cout << "decode the tag xml file stream" << endl;
	}
};

class StrategyFactory: public FactoryTemplate 
{
protected:
	void findFiles(string path) 
	{
		cout << "find the strategy xml files from the path: " << path << endl;
	}
	void decodeXml() 
	{
		cout << "decode the strategy xml file stream" << endl;
	}
};

int main() 
{
	cout << ">>> begin to build tag factory:" << endl;
	TagFactory* tagFactory = new TagFactory();
	tagFactory->initFactory("c:/fold");
	cout << ">>> begin to build strategy factory:" << endl;
	StrategyFactory* strategyFactory = new StrategyFactory();
	strategyFactory->initFactory("d:/strategy");
	return 0;
}
